/**
 * Created by tdzl2003 on 12/18/16.
 */

import React, {Component, PropTypes} from 'react';
import {
    AsyncStorage,
    Image,
    LayoutAnimation,
    NativeModules,
    StyleSheet,
    Text,
    TextInput,
    View,
    TouchableOpacity,
    Platform
} from 'react-native';
import {Actions} from 'react-native-router-flux'
import { NavigationActions } from 'react-navigation';
import Dimensions from 'Dimensions';
import MySuggestList from './MySuggestList';
import CoordinationList from './CoordinationList';
import RString from '../language/RString';

const styles = StyleSheet.create({
    body :{
        flex:1
    },
    commonHeader:{
        height: Platform.OS === 'android'? 50 : 60,
        paddingTop: Platform.OS === 'ios'? 20 : 0,
        backgroundColor:'#333238',
        flexDirection:'row',
        justifyContent:'center',
        position:'relative'
    },
    back:{
        width:30,
        position:'absolute',
        left:20,
        top:0,
        height: Platform.OS === 'android'? 50 : 60,
        paddingTop: Platform.OS === 'ios'? 20 : 0,
        justifyContent:'center'
    },
    toIndex:{
        width:30,
        position:'absolute',
        left:70,
        top:0,
        height: Platform.OS === 'android'? 50 : 60,
        paddingTop: Platform.OS === 'ios'? 20 : 0,
        justifyContent:'center'
    },
    succWrap:{
        height: Dimensions.get('window').height-50,
        backgroundColor: '#FFFFFF',
        alignItems:"center",
        paddingTop: 100
    },
    succ :{
        paddingTop: 20,
        color: '#000000',
        fontSize: 18,
        fontWeight: 'bold'
    }

});


export default class Distribute extends Component {
    constructor(props){
        super(props);
        this.state = {
            text: 'Useless Placeholder' ,
            title:RString('success_assign'),
        };
    }

    goBack = () => {
        const{navigator} = this.props;
        if(navigator){
            navigator.pop();
        }
    };
    doClose = () => {
        NativeModules.system.navTo("BACK");
    };

    _onPress = () => {
        console.warn(this.props.navigation.navigate("option"))
    };

    componentDidMount(){
        let _this = this;
        setTimeout(function () {
            const{navigator} = _this.props;
            if(navigator){
                if (global.isCoordinator) {
                    navigator.push({
                        name: "CoordinationList",
                        component: CoordinationList
                    })
                } else {
                    navigator.push({
                        name: "MySuggestList",
                        component:MySuggestList
                    });
                }
            }
        },2000);
    }

    render() {
        return (
            <View style={styles.body}>
                <View style={styles.commonHeader}>
                    <TouchableOpacity onPress={this.goBack.bind(this)} style={styles.back}>
                        <Image source={require('./img/leftArrow.png')} />
                    </TouchableOpacity>
                    <TouchableOpacity onPress={this.doClose.bind(this)} style={styles.toIndex}>
                        <Image source={require('./img/chahao.png')}/>
                    </TouchableOpacity>
                    <View style={{ justifyContent:'center' }}>
                        <Text style={{ color:'#fff',fontSize:16 }}>{this.state.title}</Text>
                    </View>
                </View>
                <View style={ styles.succWrap }>
                    <Image source={require('./img/distributeSucc.png')} />
                    <Text style={styles.succ}>{RString('success_assign')}</Text>
                    <Text style={{paddingTop:10,fontWeight:'100'}}>{RString('success_assignTo')}“{this.props.responsible}”</Text>
                </View>
            </View>
        );
    }
}
